//
//  PublicityTableViewCell.m
//  WideHelp
//
//  Created by ENERGY on 2018/8/8.
//  Copyright © 2018年 ENERGY. All rights reserved.
//

#import "PublicityTableViewCell.h"

@interface PublicityTableViewCell()
@property (nonatomic, strong)UIView * lineView;
@property (nonatomic, strong)UILabel * nameTitleLab;
@property (nonatomic, strong)UILabel * nameContentLab;
@property (nonatomic, strong)UILabel * moneyTitleLab;
@property (nonatomic, strong)UILabel * moneyContentLab;
@property (nonatomic, strong)UILabel * timeTitleLab;
@property (nonatomic, strong)UILabel * timeContentLab;
@property (nonatomic, strong)UIButton * arrowBtn;
@property (nonatomic, strong)UIImageView * iconImg;
@end

@implementation PublicityTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor whiteColor];
        __weak typeof (self)weakSelf = self;
        [self.contentView addSubview:self.lineView];
        [self.contentView addSubview:self.nameTitleLab];
        [self.contentView addSubview:self.nameContentLab];
        [self.contentView addSubview:self.moneyTitleLab];
        [self.contentView addSubview:self.moneyContentLab];
        [self.contentView addSubview:self.timeTitleLab];
        [self.contentView addSubview:self.timeContentLab];
        [self.contentView addSubview:self.arrowBtn];
        [self.contentView addSubview:self.iconImg];
        [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(weakSelf.contentView);
            make.height.mas_offset(1/WIDTH_6_SCALE);
            make.top.equalTo(weakSelf.contentView.mas_top);
        }];
        [self.iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView.mas_left).mas_offset(15/WIDTH_6_SCALE);
            make.width.height.mas_offset(70/WIDTH_6_SCALE);
            make.top.equalTo(weakSelf.lineView.mas_bottom).mas_offset(16/WIDTH_6_SCALE);
        }];
        [self.nameTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.iconImg.mas_right).mas_offset(16/WIDTH_6_SCALE);
            make.top.equalTo(weakSelf.iconImg.mas_top);
            make.height.mas_offset(14/WIDTH_6_SCALE);
        }];
        [self.nameContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.nameTitleLab.mas_right).mas_offset(10/WIDTH_6_SCALE);
            make.top.height.equalTo(weakSelf.nameTitleLab);
        }];
        [self.moneyTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.height.equalTo(weakSelf.nameTitleLab);
            make.top.equalTo(weakSelf.nameTitleLab.mas_bottom).mas_offset(14/WIDTH_6_SCALE);
        }];
        [self.moneyContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.top.equalTo(weakSelf.moneyTitleLab);
            make.left.equalTo(weakSelf.moneyTitleLab.mas_right).mas_offset(10/WIDTH_6_SCALE);
        }];
        [self.timeTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.height.equalTo(weakSelf.nameTitleLab);
            make.top.equalTo(weakSelf.moneyTitleLab.mas_bottom).mas_offset(14/WIDTH_6_SCALE);
        }];
        [self.timeContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.timeTitleLab.mas_right).mas_offset(10/WIDTH_6_SCALE);
            make.top.height.equalTo(weakSelf.timeTitleLab);
        }];
//        [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.left.right.equalTo(weakSelf.contentView);
//            make.height.mas_offset(1/WIDTH_6_SCALE);
//        }];
        [self.arrowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(weakSelf.contentView).mas_offset(-15/WIDTH_6_SCALE);
            make.width.mas_offset(6/WIDTH_6_SCALE);
            make.height.mas_offset(10/WIDTH_6_SCALE);
            make.top.equalTo(weakSelf.lineView.mas_bottom).mas_offset(45/WIDTH_6_SCALE);
        }];
    }return self;
}

- (UILabel *)nameTitleLab{
    if (!_nameTitleLab) {
        _nameTitleLab = [[UILabel alloc] init];
        _nameTitleLab.font = DEF_FontSize_14;
        _nameTitleLab.textColor = [UIColor blackColor];
        _nameTitleLab.textAlignment = NSTextAlignmentLeft;
    }return _nameTitleLab;
}
- (UILabel *)nameContentLab{
    if (!_nameContentLab) {
        _nameContentLab = [[UILabel alloc] init];
        _nameContentLab.font = DEF_FontSize_14;
        _nameContentLab.textColor = [UIColor blackColor];
        _nameContentLab.textAlignment = NSTextAlignmentLeft;
    }return _nameContentLab;
}
- (UILabel *)moneyTitleLab{
    if (!_moneyTitleLab) {
        _moneyTitleLab = [[UILabel alloc] init];
        _moneyTitleLab.font = DEF_FontSize_14;
        _moneyTitleLab.textColor = [UIColor blackColor];
        _moneyTitleLab.textAlignment = NSTextAlignmentLeft;
    }return _moneyTitleLab;
}
- (UILabel *)moneyContentLab{
    if (!_moneyContentLab) {
        _moneyContentLab = [[UILabel alloc] init];
        _moneyContentLab.font = DEF_FontSize_14;
        _moneyContentLab.textColor = [UIColor blackColor];
        _moneyContentLab.textAlignment = NSTextAlignmentLeft;
    }return _moneyContentLab;
}
- (UILabel *)timeTitleLab{
    if (!_timeTitleLab) {
        _timeTitleLab = [[UILabel alloc] init];
        _timeTitleLab.font = DEF_FontSize_14;
        _timeTitleLab.textColor = [UIColor blackColor];
        _timeTitleLab.textAlignment = NSTextAlignmentLeft;
    }return _timeTitleLab;
}
- (UILabel *)timeContentLab{
    if (!_timeContentLab) {
        _timeContentLab = [[UILabel alloc] init];
        _timeContentLab.font = DEF_FontSize_14;
        _timeContentLab.textColor = [UIColor blackColor];
        _timeContentLab.textAlignment = NSTextAlignmentLeft;
    }return _timeContentLab;
}
- (UIView *)lineView{
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = getColor(@"eeeeee");
    }return _lineView;
}
- (UIImageView *)iconImg{
    if (!_iconImg) {
        _iconImg = [[UIImageView alloc] init];
        _iconImg.image = [UIImage imageNamed:@"head_login_icon"];
    }return _iconImg;
}
- (UIButton *)arrowBtn{
    if (!_arrowBtn) {
        _arrowBtn = [[UIButton alloc] init];
        [_arrowBtn setBackgroundColor:[UIColor orangeColor]];
    }
    return _arrowBtn;
}
- (void)setModel:(NSDictionary *)model{
    _model = model;
//    self.iconImg.image = [UIImage imageNamed:model[@"image"]];
    self.nameContentLab.text = model[@"name"];
    self.moneyContentLab.text = model[@"money"];
    self.timeContentLab.text = model[@"time"];
}
@end
